class Image < ActiveRecord::Base
    belongs_to :content
    belongs_to :test
    belongs_to :new
    has_attachment :content_type => :image,
                  :storage => :file_system,
                  :min_size => 0.kilobytes,
                  :max_size => 2.megabytes,
                  :resize_to => '640x480>',
                  :thumbnails => { :thumb => '100x100>' },
                  :path_prefix => 'public/images/uploads'
    validates_as_attachment
    
    def  full_filename(thumbnail = nil)      
        file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix]      
        case self.thumbnail      
        when "thumb"        
          File.join(RAILS_ROOT, file_system_path, 'thumb', thumbnail_name_for(thumbnail))      
        else        
          File.join(RAILS_ROOT, file_system_path, 'fullsize', thumbnail_name_for(thumbnail))      
        end    
   end 
end
